package com.heima.behavior.controller.v1;

import com.heima.behavior.service.ApBehaviorService;
import com.heima.model.behavior.dtos.ApArticleCountDto;
import com.heima.model.behavior.dtos.IsLikeDto;
import com.heima.model.behavior.dtos.IsUnlikeDto;
import com.heima.model.behavior.dtos.LikesBehaviorDto;
import com.heima.model.behavior.dtos.UnLikesBehaviorDto;
import com.heima.model.behavior.pojos.ApArticleLike;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping
@Api(tags = "用户行为管理")
public class ApBehaviorController {
    @Autowired
    private ApBehaviorService apBehaviorService;
    @PostMapping("/api/v1/likes_behavior")
    @ApiOperation("点赞行为")
    public ResponseResult likeBehavior(@RequestBody LikesBehaviorDto dto){
        log.info("点赞行为：{}",dto);
        apBehaviorService.likeBehavior(dto);
        return ResponseResult.okResult("ok");
    }
    @PostMapping("/api/v1/read_behavior")
    @ApiOperation("阅读次数")
    public ResponseResult readBehavior(@RequestBody ApArticleCountDto dto){
        log.info("阅读次数：{}",dto);
        apBehaviorService.counRehavior(dto);
        return ResponseResult.okResult("ok");
    }
    @PostMapping("/api/v1/un_likes_behavior")
    @ApiOperation("不喜欢")
    public ResponseResult unLikeBehavior(@RequestBody UnLikesBehaviorDto dto){
        log.info("不喜欢：{}",dto);
        apBehaviorService.unlikesBehavior(dto);
        return ResponseResult.okResult("ok");
    }


    @PostMapping("/api/v1/likes_behavior/isLike")
    public Boolean isLike(@RequestBody IsLikeDto isLikeDto) {
        return apBehaviorService.isLike(isLikeDto);
    }

    @PostMapping("/api/v1/likes_behavior/isUnlike")
    public Boolean isUnlike(@RequestBody IsUnlikeDto isUnlikeDto) {
        return apBehaviorService.isUnlike(isUnlikeDto);
    }
}
